Skip to content

fix(rag): update agent to support agent-starter-pack and vertex rag engine deployment#1237

Merged
happyhuman merged 2 commits intogoogle:mainfrom
cnemri:fix-rag-agent-garden-deployment
Mar 12, 2026
Merged

fix(rag): update agent to support agent-starter-pack and vertex rag engine deployment#1237
happyhuman merged 2 commits intogoogle:mainfrom
cnemri:fix-rag-agent-garden-deployment

Conversation

@cnemri
Copy link
Collaborator

@cnemri cnemri commented Mar 12, 2026

Description

Updates the RAG agent template to fully support the Agent Garden / Agent Starter Pack deployment lifecycles and fixes several underlying bugs related to Vertex AI Agent Engine and RAG Corpus region routing.

Key Changes

  • Agent Starter Pack Lifecycle Hooks: Added a Makefile with install and backend hooks so that Agent Starter Pack automatically triggers the interactive RAG Corpus generation prompt and the IAM permissions script during scaffolding and deployment.
  • Script Robustness: Moved grant_permissions.sh out of the deployment folder into rag/shared_libraries so it isn't erased during ASP terraform template overrides.
  • Dynamic .env Context: prepare_corpus_and_data.py now prioritizes reading from the cwd .env file first so it correctly updates the newly scaffolded project's state.
  • Vertex Region Fix: Removed hardcoded global location from __init__.py and added dynamic region extraction in agent.py. This fixes the 400 INVALID_ARGUMENT (RESOURCE_PROJECT_INVALID) error by ensuring the Vertex SDK uses the region where the RAG corpus was actually created (e.g., us-central1) rather than forcing cross-regional requests.
  • Graceful Tool Handling: Updated agent.py to cleanly omit the VertexAiRagRetrieval tool if no RAG_CORPUS ID is configured in the environment, preventing startup crashes.
  • 2025 Alphabet 10-K: Updated the corpus preparation script, README, and test queries to use the latest 2025 financial report URL since the 2024 URL is throwing a 403 Forbidden.

Testing

Validated locally via pure ASP commands: uvx agent-starter-pack create ... && cd ... && make install && make backend.

…ngine deployment

* Move grant_permissions.sh to shared_libraries so it survives ASP scaffolding
* Add Makefile hooks (setup_corpus, grant_permissions) to natively integrate with ASP `make install` and `make backend` lifecycles
* Update prepare_corpus_and_data.py to intelligently load .env from scaffolded cwd and update to 2025 GOOG-10-K URL
* Fix agent.py to conditionally load retrieval tool to avoid crash on empty corpus and remove hardcoded location from __init__.py so vertex RAG correctly infers region from the corpus
* Update README to reflect 2025 report and new ASP workflow
@happyhuman happyhuman merged commit cbf265d into google:main Mar 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants